const express = require('express')
const router = express.Router()

const articleController = require('../controller/ArticleController')

/**
 * @api {get} /api/v1/content/article/list 获取文章列表
 * @apiDescription /api/v1/content/article/list
 * @apiName list
 * @apiGroup Article
 * @apiParam {string} [title]     文章名称
 * @apiParam {number} [categoryId]文章分类
 * @apiParam {string} [author]    作者
 * @apiParam {string} [original]  是否原创，1原创
 * @apiParam {number} [top]       是否置顶，1置顶
 * @apiParam {number} [status]    状态
 * @apiParam {number} [page]      当前页
 * @apiParam {number} [pageSize]  分页大小
 * @apiSampleRequest /api/v1/content/article/list
 * @apiSuccess {number} code 响应状态码
 * @apiSuccess {Article[]} data 文章信息
 * @apiSuccessExample {json} Success-Response:
 *  HTTP/1.1 200 OK
 *  {
 *      "code" : 200,
 *      "data" : [
 *        {
 *          "id":12,
 *          "title":"Deprecation Warning: Using \/ for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
 *          "user_id":"1",
 *          "author":"kuake",
 *          "cover_image":"http:\/\/qiniu.1024ape.com\/img\/blog\/8a1079f4075b8c7864c0c85d56c79ed5.png",
 *          "qrcode_path":null,
 *          "is_markdown":1,
 *          "content":"<p><strong>针对于sass变量进行&ldquo;\/&rdquo;运算，导致出现如下警告信息：<\/strong><\/p>\r\n\r\n<p><span style=\"color:#c0392b\">Deprecation Warning: Using \/ for division outside of calc() is deprecated and will be removed in Dart<\/span><span style=\"color:#3498db\">&nbsp;<\/span><a href=\"https:\/\/so.csdn.net\/so\/search?q=Sass&amp;spm=1001.2101.3001.7020\" target=\"_blank\"><span style=\"color:#3498db\">Sass<\/span><\/a><span style=\"color:#c0392b\">&nbsp;2.0.0.<\/span><\/p>\r\n\r\n<p><img src=\"http:\/\/qiniu.1024ape.com\/img\/blog\/caf05ab26127d26ba4a63e585f077176.png\" style=\"height:361px; width:821px\" \/><\/p>\r\n\r\n<p>出现以上警告的原因，是因为sass 新版本目前弃用了&ldquo;\/&rdquo;的用法而导致<\/p>\r\n\r\n<p><strong>解决办法：<\/strong><\/p>\r\n\r\n<ol>\r\n\t<li>npm install -g sass-migrator<\/li>\r\n\t<li>进入项目node_modules文件<\/li>\r\n\t<li>执行sass-migrator division **\/*.scss<\/li>\r\n<\/ol>\r\n",
 *          "content_md":"<p><strong>针对于sass变量进行&ldquo;\/&rdquo;运算，导致出现如下警告信息：<\/strong><\/p>\r\n\r\n<p><span style=\"color:#c0392b\">Deprecation Warning: Using \/ for division outside of calc() is deprecated and will be removed in Dart<\/span><span style=\"color:#3498db\">&nbsp;<\/span><a href=\"https:\/\/so.csdn.net\/so\/search?q=Sass&amp;spm=1001.2101.3001.7020\" target=\"_blank\"><span style=\"color:#3498db\">Sass<\/span><\/a><span style=\"color:#c0392b\">&nbsp;2.0.0.<\/span><\/p>\r\n\r\n<p><img src=\"http:\/\/qiniu.1024ape.com\/img\/blog\/caf05ab26127d26ba4a63e585f077176.png\" style=\"height:361px; width:821px\" \/><\/p>\r\n\r\n<p>出现以上警告的原因，是因为sass 新版本目前弃用了&ldquo;\/&rdquo;的用法而导致<\/p>\r\n\r\n<p><strong>解决办法：<\/strong><\/p>\r\n\r\n<ol>\r\n\t<li>npm install -g sass-migrator<\/li>\r\n\t<li>进入项目node_modules文件<\/li>\r\n\t<li>执行sass-migrator division **\/*.scss<\/li>\r\n<\/ol>\r\n",
 *          "top":0,
 *          "category_id":2,
 *          "status":1,
 *          "recommended":0,
 *          "slider":0,
 *          "slider_img":null,
 *          "original":1,
 *          "description":"针对于sass变量进行“\/”运算，导致出现如下警告信息：\r\n\r\nDeprecation Warning: Using \/ for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.出现以上警告的原因，是因为sass 新版本目前弃用了“\/”的用法而导致；解决办法：\r\n\r\nnpm install -g sass-migrator\r\n进入项目node_modules文件\r\n执行sass-migrator division **\/*.scss",
 *          "keywords":"css,sass",
 *          "comment":1,
 *          "create_time":"2022\/11\/30 00:14:57",
 *          "update_time":"2022\/11\/30 00:14:57"
 *        }
 *      ],
 *      "message" : "请求成功",
 *  }
 * @apiVersion v1.0.0
 */
router.get('/list', articleController.seletArticleList)


/**
 * @api {get} /api/v1/content/article/:id 根据id查询文章信息
 * @apiDescription /api/v1/content/article/:id
 * @apiName getArticleById
 * @apiGroup Article
 * @apiParam {number} id  文章id
 * @apiSampleRequest /api/v1/content/article/:id
 * @apiSuccess {number} code 响应状态码
 * @apiSuccess {Article} data 文章信息
 * @apiSuccessExample {json} Success-Response:
 *  HTTP/1.1 204 OK
 *  {
 *      "code" : 204,
 *      "data" :  {
 *          "id":12,
 *          "title":"Deprecation Warning: Using \/ for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
 *          "user_id":"1",
 *          "author":"kuake",
 *          "cover_image":"http:\/\/qiniu.1024ape.com\/img\/blog\/8a1079f4075b8c7864c0c85d56c79ed5.png",
 *          "qrcode_path":null,
 *          "is_markdown":1,
 *          "content":"<p><strong>针对于sass变量进行&ldquo;\/&rdquo;运算，导致出现如下警告信息：<\/strong><\/p>\r\n\r\n<p><span style=\"color:#c0392b\">Deprecation Warning: Using \/ for division outside of calc() is deprecated and will be removed in Dart<\/span><span style=\"color:#3498db\">&nbsp;<\/span><a href=\"https:\/\/so.csdn.net\/so\/search?q=Sass&amp;spm=1001.2101.3001.7020\" target=\"_blank\"><span style=\"color:#3498db\">Sass<\/span><\/a><span style=\"color:#c0392b\">&nbsp;2.0.0.<\/span><\/p>\r\n\r\n<p><img src=\"http:\/\/qiniu.1024ape.com\/img\/blog\/caf05ab26127d26ba4a63e585f077176.png\" style=\"height:361px; width:821px\" \/><\/p>\r\n\r\n<p>出现以上警告的原因，是因为sass 新版本目前弃用了&ldquo;\/&rdquo;的用法而导致<\/p>\r\n\r\n<p><strong>解决办法：<\/strong><\/p>\r\n\r\n<ol>\r\n\t<li>npm install -g sass-migrator<\/li>\r\n\t<li>进入项目node_modules文件<\/li>\r\n\t<li>执行sass-migrator division **\/*.scss<\/li>\r\n<\/ol>\r\n",
 *          "content_md":"<p><strong>针对于sass变量进行&ldquo;\/&rdquo;运算，导致出现如下警告信息：<\/strong><\/p>\r\n\r\n<p><span style=\"color:#c0392b\">Deprecation Warning: Using \/ for division outside of calc() is deprecated and will be removed in Dart<\/span><span style=\"color:#3498db\">&nbsp;<\/span><a href=\"https:\/\/so.csdn.net\/so\/search?q=Sass&amp;spm=1001.2101.3001.7020\" target=\"_blank\"><span style=\"color:#3498db\">Sass<\/span><\/a><span style=\"color:#c0392b\">&nbsp;2.0.0.<\/span><\/p>\r\n\r\n<p><img src=\"http:\/\/qiniu.1024ape.com\/img\/blog\/caf05ab26127d26ba4a63e585f077176.png\" style=\"height:361px; width:821px\" \/><\/p>\r\n\r\n<p>出现以上警告的原因，是因为sass 新版本目前弃用了&ldquo;\/&rdquo;的用法而导致<\/p>\r\n\r\n<p><strong>解决办法：<\/strong><\/p>\r\n\r\n<ol>\r\n\t<li>npm install -g sass-migrator<\/li>\r\n\t<li>进入项目node_modules文件<\/li>\r\n\t<li>执行sass-migrator division **\/*.scss<\/li>\r\n<\/ol>\r\n",
 *          "top":0,
 *          "category_id":2,
 *          "status":1,
 *          "recommended":0,
 *          "slider":0,
 *          "slider_img":null,
 *          "original":1,
 *          "description":"针对于sass变量进行“\/”运算，导致出现如下警告信息：\r\n\r\nDeprecation Warning: Using \/ for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.出现以上警告的原因，是因为sass 新版本目前弃用了“\/”的用法而导致；解决办法：\r\n\r\nnpm install -g sass-migrator\r\n进入项目node_modules文件\r\n执行sass-migrator division **\/*.scss",
 *          "keywords":"css,sass",
 *          "comment":1,
 *          "create_time":"2022\/11\/30 00:14:57",
 *          "update_time":"2022\/11\/30 00:14:57"
 *        },
 *      "message" : "删除成功",
 *  }
 * @apiVersion v1.0.0
 */
router.get('/:id', articleController.selectArticleById)


/**
 * @api {post} /api/v1/content/article/add 添加文章
 * @apiDescription /api/v1/content/article/add
 * @apiName add
 * @apiGroup Article
 * @apiParam {string} [title]     文章名称
 * @apiParam {number} [categoryId]文章分类
 * @apiParam {string} [coverImage]文章封面图
 * @apiParam {string} [qrcodePath]文章二维码地址
 * @apiParam {number} [isMarkdown]是否是markdown格式
 * @apiParam {string} [content]   文章内容
 * @apiParam {string} [contentMd] markdown内容
 * @apiParam {number} [recommended]是否推荐
 * @apiParam {number} [slider]    是否轮播
 * @apiParam {string} [sliderImg] 轮播图地址
 * @apiParam {string} [keywords]  文章关键词
 * @apiParam {string} [description]文章描述，SEO优化
 * @apiParam {string} [author]    作者
 * @apiParam {string} [original]  是否原创，1原创
 * @apiParam {number} [top]       是否置顶，1置顶
 * @apiParam {number} [status]    状态
 * @apiParam {number} [comment]   是否开启评论
 * @apiSampleRequest /api/v1/content/article/add
 * @apiSuccess {number} code 响应状态码
 * @apiSuccess {Article[]} data 文章信息
 * @apiSuccessExample {json} Success-Response:
 *  HTTP/1.1 201 OK
 *  {
 *      "code" : 201,
 *      "data" : true,
 *      "message" : "添加文章成功",
 *  }
 * @apiVersion v1.0.0
 */
router.post('/add', articleController.addArticle)


/**
 * @api {put} /api/v1/content/article/update 修改文章
 * @apiDescription /api/v1/content/article/update
 * @apiName update
 * @apiGroup Article
 * @apiParam {string} [articleId] 文章id
 * @apiParam {string} [title]     文章名称
 * @apiParam {number} [categoryId]文章分类
 * @apiParam {string} [coverImage]文章封面图
 * @apiParam {string} [qrcodePath]文章二维码地址
 * @apiParam {number} [isMarkdown]是否是markdown格式
 * @apiParam {string} [content]   文章内容
 * @apiParam {string} [contentMd] markdown内容
 * @apiParam {number} [recommended]是否推荐
 * @apiParam {number} [slider]    是否轮播
 * @apiParam {string} [sliderImg] 轮播图地址
 * @apiParam {string} [keywords]  文章关键词
 * @apiParam {string} [description]文章描述，SEO优化
 * @apiParam {string} [author]    作者
 * @apiParam {string} [original]  是否原创，1原创
 * @apiParam {number} [top]       是否置顶，1置顶
 * @apiParam {number} [status]    状态
 * @apiParam {number} [comment]   是否开启评论
 * @apiSampleRequest /api/v1/content/article/update
 * @apiSuccess {number} code 响应状态码
 * @apiSuccess {Article[]} data 文章信息
 * @apiSuccessExample {json} Success-Response:
 *  HTTP/1.1 208 OK
 *  {
 *      "code" : 208,
 *      "data" : true,
 *      "message" : "修改成功",
 *  }
 * @apiVersion v1.0.0
 */
router.put('/update', articleController.updateArticle)


/**
 * @api {delete} /api/v1/content/article/delete 删除文章
 * @apiDescription /api/v1/content/article/delete
 * @apiName delete
 * @apiGroup Article
 * @apiBody {number} id 文章id
 * @apiSampleRequest /api/v1/content/article/delete
 * @apiSuccess {number} code 响应状态码
 * @apiSuccess {Article[]} data 文章信息
 * @apiSuccessExample {json} Success-Response:
 *  HTTP/1.1 204 OK
 *  {
 *      "code" : 204,
 *      "data" : true,
 *      "message" : "删除成功",
 *  }
 * @apiVersion v1.0.0
 */
router.delete('/delete', articleController.deleteArticle)

module.exports = router